import { createStore } from 'vuex'

const store = createStore({
  state() {
    return {
      currentUser: JSON.parse(localStorage.getItem('currentUser') || '{}')
    }
  },
  mutations: {
    updateUser(state, user) {
      state.currentUser = user
      localStorage.setItem('currentUser', JSON.stringify(user))
    }
  }
})

export default store 